<template>
	<div class="redictPage-body">
		页面加载中,请稍等...
	</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useStore } from '@/store'
import { getFxInstance } from '@/js/instance'
export default defineComponent({
	name: 'redictPage',
	setup () {
		const fxInstance = getFxInstance()
		const route = useRoute()
		const router = useRouter()
		const store = useStore()
		const token = route.query.token as string
		const routerPath = route.query.routerPath || 'home'
		const routerPathQuery = route.query.routerPathQuery ? fxInstance.$fxUtils.JSONparse<string>(route.query.routerPathQuery as string) : {}
		const loginHandler = () => {
			store.commit('SET_LOGINER', {
				token,
				baseUrl: ''
			})
			return loginFinishHandler()
		}
		// }}}
		const getCurrentUser = () => {
			return store.dispatch('syncLoginer')
		}
		const getModuleAuth = () => {
			return store.dispatch('syncModuleAuth')
		}
		const loginFinishHandler = () => {
			return Promise.all([getCurrentUser(), getModuleAuth()])
		}
		const setSystemByRoute = () => {
			store.commit('SET_SYSTEM', {
				isIframe: route.query.iframe === 'true',
				isByRedirectPage: true
			})
		}
		setSystemByRoute()
		loginHandler().then(() => {
			router.push({ path: routerPath as string, query: routerPathQuery })
		})
		return {
		}
	}
})
</script>
<style lang="scss" scoped>
@import "$assets/stylus/varsty";
.redictPage-body {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    font-size:30px
}
</style>
